package m1;

import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;

import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * 生产者
 * @author 郭鲁政
 */
public class Producer {
    public static void main(String[] args) throws MQClientException, MQBrokerException, RemotingException, InterruptedException {
        DefaultMQProducer producer = new DefaultMQProducer("prod-group");
        producer.setNamesrvAddr("192.168.64.141:9876");
        producer.start();
        while (true){
            System.out.println("请输入消息:");
            String s = new Scanner(System.in).nextLine();
            Message message = new Message("Topic", "TagA", s.getBytes(StandardCharsets.UTF_8));
            message.setDelayTimeLevel(3);
            System.out.println(producer.send(message));
        }
    }
}
